console.log(111,config)


const port =config.port

//解决安全策略问题
const cspMetaTag = `<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src http://127.0.0.1:${port}">`;
document.head.insertAdjacentHTML('beforeend', cspMetaTag); // 将CSP策略插入到<head>标签的末尾

const $url = "http://127.0.0.1:" + port
var namelist = ["shijue","ceshi","yonghu"]

// 点击切换到个人中心
document.getElementById('zhongxing').addEventListener('click', function() {
    qiehuan('ceshi',namelist)
});

// 点击切换到监控界面
document.getElementById('jiankong').addEventListener('click', function() {
    qiehuan('shijue',namelist)
});

// 点击切换到控制界面
document.getElementById('kongzhi').addEventListener('click', function() {
    qiehuan('yonghu',namelist)
});

// 切换界面
function qiehuan(name,namelist) {
   for(var item in namelist ){
        if(namelist[item] == name ){
            var namedoc = document.getElementById(name);
            namedoc.style.display = "block";
        }
        else{
            var nonedoc =  document.getElementById(namelist[item]);
            nonedoc.style.display = "none";
        }
   }
}

async function controlexe(name) {
    let result = await http(
        {
        url: $url+"/Controlexe",
        type: "POST",
        data:{switch:name},
        header:{contextType: "application/json"},
    })
    // console.log(result)
  }
  
 // 控制程序开关
document.getElementById('openmp4').addEventListener('click', function() {
    controlexe('openmp4')
});


